package com.example.administrator.biyesheji_print.Activity;

import android.app.AlertDialog;
import android.content.Intent;
import android.os.Bundle;
import android.os.Looper;
import android.support.annotation.Nullable;
import android.view.View;
import android.widget.Button;

import com.example.administrator.biyesheji_print.MainActivity;
import com.example.administrator.biyesheji_print.R;

import butterknife.BindView;
import butterknife.ButterKnife;
import dmax.dialog.SpotsDialog;

/**
 * Created by Administrator on 2018/3/28.
 */

public class LoginActivity extends ChenJinActivity implements View.OnClickListener {
    @BindView(R.id.bt_login)
    Button btLogin;
    private AlertDialog spotsDialog;

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_login);
        ButterKnife.bind(this);
        initUI();
    }

    /**
     * 控件init
     */
    private void initUI() {
        btLogin.setOnClickListener(this);
    }

    @Override
    public void onClick(View v) {
        switch (v.getId()){
            case R.id.bt_login:
                spotsDialog = new SpotsDialog(LoginActivity.this);
                spotsDialog.show();
                showDialog();

                break;
        }
    }

    @Override
    protected void onPause() {
        super.onPause();
        spotsDialog.dismiss();
    }

    private void showDialog() {
        new Thread(){
            @Override
            public void run() {
                try {
                    Thread.sleep(200);
                    Intent intent = new Intent(LoginActivity.this, MainActivity.class);
                    startActivity(intent);
                    finish();
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }

            }
        }.start();
    }
}
